package com.intelligent.health.setmeal.feign.fallback;

import com.intelligent.health.setmeal.feign.SetMealFeignClient;
import entity.R;
import entity.ResultCodeEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.HashMap;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: torlesse-liang
 * @Date: 2022/03/26/1:20
 * @Description: SetMealFallBackFactory
 */
@Slf4j
@Component
public class SetMealFallBackFactory implements FallbackFactory<SetMealFeignClient> {
    @Override
    public SetMealFeignClient create(Throwable cause) {
        return new SetMealFeignClient() {

            @Override
            public R queryCheckItems(HashMap<String, Object> hashMap) {
                log.error("获取检查项失败: {}",hashMap);
                return R.setResult(ResultCodeEnum.QUERY_ERROR);
            }

            @Override
            public R queryCheckGroups(HashMap<String, Object> hashMap) {
                log.error("获取检查组失败: {}",hashMap);
                return R.setResult(ResultCodeEnum.QUERY_ERROR);
            }

            @Override
            public R querySetMeals(HashMap<String, Object> hashMap) {
                log.error("获取用套餐失败: {}",hashMap);
                return R.setResult(ResultCodeEnum.QUERY_ERROR);
            }
        };
    }
}
